var http = require("http");
var server = http.createServer();
var fs = require("fs");
server.listen(8000, function () {
    console.log('服务器启动成功!');
})
fs.readFile("../冒险岛官网/index.html", function (error, data) {
    server.on("request", function (req, res) {
        res.setHeader("Content-Type", "text/html;charset=utf-8");
        console.log("客户端接入成功输入的URL为" + req.url);
        var url = req.url;
        if (error) {
            res.end("读取失败，请检查代码");
        } else if (url == "/mxd") {
            res.end(data);

        } else if (url == "/pic") {
            fs.readFile("./data/slonepic.png", function (error, data) {
                if (error) {
                    res.end("数据错误");
                } else {
                    res.setHeader("Content-Type", "image/jpg;charset=utf-8");
                    res.end(data);
                }
            })
        } else {
            res.end("404! nofound!");
        }
    })
})

/* res.setHeader("Content-Type","text/html; charset=utf-8");  */